package com.hl;

import com.hl.entity.Teacher;
import com.hl.entity.TeacherAndCollege;
import com.hl.mapper.TeacherMapper;
import com.hl.util.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.io.IOException;
import java.util.List;
/**
 * 多表查询测试
 * */
public class Test5ManyTables {
    public static void main(String[] args) throws IOException {
        SqlSession sqlSession = MybatisUtils.getSqlSession();
        TeacherMapper mapper = sqlSession.getMapper(TeacherMapper.class);
        System.out.println("-----------------------方式一------------------------------");
        List<TeacherAndCollege> list1=mapper.selectTeacherAndCollege1();
        for (TeacherAndCollege teacherAndCollege : list1) {
            System.out.println(teacherAndCollege);
        }

        System.out.println("-----------------------方式二------------------------------");
        List<Teacher> list = mapper.selectTeacherAndCollege();
        for (Teacher teacher : list) {
            System.out.println(teacher);
        }

        System.out.println("-----------------------方式三------------------------------");
        List<Teacher> list3=mapper.selectTeacherAndCollege3();
        for (Teacher teacher : list3) {
            System.out.println(teacher);
        }


//        System.out.println("-----------------------1对多-------------------------------");
//        List<Teacher> list2 = mapper.selectTeacherAndCourse();
//        for (Teacher teacher : list2) {
//            System.out.println(teacher);
//        }
//        System.out.println("-----------------------1对多和1对多-------------------------------");
//        List<Teacher> list3 = mapper.selectTeacherAndCollegeAndCourse();
//        for (Teacher teacher : list3) {
//            System.out.println(teacher);
//        }
    }
}
